package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta  `path:"/comps" tags:"组件管理" method:"get" summary:"组件列表"`
	Name    string `json:"name"        description:"组件名称"`
	AppCode string `json:"appCode"      description:"应用编码"`
	Type    int    `json:"type"        description:"组件类型: 前端1和后端2"`
	Page    int    `json:"page"   v:"required|min:1"     description:"页码"`
	Size    int    `json:"size" v:"required|between:1,100"       description:"每页条数"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []CompRes `json:"data"`
	Total  int       `json:"total"`
}

type CompRes struct {
	Id          int64  `json:"id" description:""`
	AppCode     string `json:"appCode"      description:"应用编码"`
	Name        string `json:"name"        description:"组件名称"`
	Type        int    `json:"type"        description:"组件类型: 前端1和后端2"`
	Description string `json:"description" description:"组件描述"`
}

type AddReq struct {
	g.Meta      `path:"/comps" tags:"组件管理" method:"post" summary:"添加组件"`
	AppCode     string `json:"appCode"  v:"required#必需输入组件编码"    description:"应用编码"`
	Name        string `json:"name"   v:"required#必需输入组件名"     description:"组件名称"`
	Type        int    `json:"type"        description:"组件类型: 前端1和后端2"`
	Description string `json:"description" description:"组件描述"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"组件Id"`
}

type UpdateReq struct {
	g.Meta      `path:"/comps/{id}" tags:"组件管理" method:"put" summary:"更新组件"`
	Id          int64  `query:"id" json:"id" v:"required|min:1" description:"组件Id"`
	AppCode     string `json:"appCode"      description:"应用编码"`
	Name        string `json:"name"      description:"组件名称"`
	Type        int    `json:"type"      description:"组件类型: 前端1和后端2"`
	Description string `json:"description" description:"组件描述"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteReq struct {
	g.Meta `path:"/comps/{id}" tags:"组件管理" method:"delete" summary:"删除组件"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}

type InfoReq struct {
	g.Meta `path:"/comps/{id}" tags:"组件管理" method:"get" summary:"组件详情"`
	Id     int64 `query:"id" v:"required|min:1"`
}

type InfoRes struct {
	g.Meta `mime:"application/json"`
}

type TypesReq struct {
	g.Meta `path:"/comps/types" tags:"组件管理" method:"get" summary:"组件类型列表"`
}
type TypesRes struct {
	g.Meta `mime:"application/json"`
	Data   []consts.DdicType1 `json:"data"`
}

// input and output structs
type ListInput struct {
	Name    string `json:"name"        description:"组件名称"`
	AppCode string `json:"appCode"      description:"组件编码"`
	Type    int    `json:"type"        description:"组件类型: 前端1和后端2"`
	Page    int    `json:"page"   v:"required|min:1"     description:"页码"`
	Size    int    `json:"size" v:"required|between:1,100"       description:"每页条数"`
}
type ListOutput struct {
	Data  []entity.AppComponent `json:"data" description:"组件列表"`
	Total int                   `json:"total"        description:"总条数"`
}

type AddInput struct {
	do.AppComponent
}
type AddOutput struct {
	Id int64 `json:"id" description:"新增组件id"`
}

type UpdateInput struct {
	do.AppComponent
}

type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteInput struct {
	Id int64 `json:"id" v:"required#ID不能为空"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}

type InfoInput struct {
	Id int64 `json:"id" v:"required#ID不能为空"`
}

type InfoOutput struct {
}
